#include "my_head.h"

bool Order_Flight(p_order_node  head,p_flight_node head2)
{
    char a[20]={0};
    if(head==NULL)
    {
        printf("error\n");
        return false;
    }
    if(head2==NULL)
    {
        printf("error\n");
        return false;
    }
    //申请新的预订节点堆空间
    p_order_node newnode=calloc(1,sizeof(order_node));
    if(newnode==NULL)
    {
        printf("%s %d error\n",__FUNCTION__,__LINE__);
        return false;
    }
    printf("请输入你想要预订的航班的航班号:");
    scanf("%s",a);
    p_flight_node p=head2->next;
    while(p!=NULL&&strcmp(a,p->data.flight_Number)!=0)
    {
        p=p->next;
    }
    if(p!=NULL)
    {
        newnode->next=head->next;
        head->next=newnode;//插入链表
        //预订航班号信息
        strcpy(newnode->data.flight_Number,p->data.flight_Number);
        //预订航班机型信息
        strcpy(newnode->data.aircraft_Model,p->data.aircraft_Model);
        //预订航班预计起飞时间信息
        strcpy(newnode->data.departure_Time,p->data.departure_Time);
        //预订航班预计降落时间信息
        strcpy(newnode->data.arrival_Time,p->data.arrival_Time);
        //预订航班班期信息
        strcpy(newnode->data.flight_Schedule,p->data.flight_Schedule);
        //预订航班起飞机场信息
        strcpy(newnode->data.departure_Airport,p->data.departure_Airport);
        //预订航班目的机场信息
        strcpy(newnode->data.arrival_Airport,p->data.arrival_Airport);
        printf("预订成功！\n");
        printf("===============\n");
        return true;
    }else
    {
        printf("未找到该航班！\n");
        printf("=============\n");
        return false;
    }
}